  /**
   * 
   * @module description:后端从数据库根据监测点位操作元素信息文件
   * @author 吴迪嘉
   */
const theDatabase = require('../../config/db.js').theDb; //引入数据库
const pointInfoSchema = theDatabase.import('../../schema/point_info.js'); 

class PointInfoModel {
    static async getAllData(project_num) {

    const AllProjectData = await pointInfoSchema.findAll({
        where:{
            project_num: project_num
        }
    })

    return AllProjectData
}
static async getpointMarkerInfo(project_num) {

    const AllProjectData = await pointInfoSchema.findAll({
         where:{
             project_num:project_num
         }
    })

    return AllProjectData
}


static async getProjectnumByPointnum(point_num) {

    const AllProjectData = await pointInfoSchema.findOne({
        where:{
            point_num: point_num
        }
    })

    return AllProjectData.project_num
}

static async getIntroByPointnum(point_num) {

    const AllProjectData = await pointInfoSchema.findOne({
        where:{
            point_num: point_num
        }
    })
    
    return AllProjectData.remarks
}
static async getPointnumByProjectnum(Project_num) {

    const AllProjectData = await pointInfoSchema.findAll({
        where:{
            Project_num: Project_num
        }
    })
    
    var list=[]
    for (let i of AllProjectData) {
       list.push(i.point_num)


    }
    return list
}

static async UpdatedifferentCount(id,all_count) {


    await pointInfoSchema.update({
        
        count:all_count,
        
    },{
        where:{
            point_num:id
        }
    })
    return true
}

}
module.exports = PointInfoModel